package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltPeakValleyTimeConfigReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltPeakValleyTimeConfigRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltPeakValleyTimeConfig;
import java.util.Objects;

/**
 * BeltPeakValleyTimeConfig DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-10-24
 */
public class BeltPeakValleyTimeConfigAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltPeakValleyTimeConfig dto2entity(BeltPeakValleyTimeConfigReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltPeakValleyTimeConfig entity = new BeltPeakValleyTimeConfig();
    entity.setStartTime(dto.getStartTime());
    entity.setEndTime(dto.getEndTime());
    entity.setElectricityPrice(dto.getElectricityPrice());
    entity.setValleyType(dto.getValleyType());
    entity.setRemark(dto.getRemark());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltPeakValleyTimeConfig dto2entity(BeltPeakValleyTimeConfigReqDTO dto, BeltPeakValleyTimeConfig entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getStartTime())) {
      entity.setStartTime(dto.getStartTime());
    }
    if(Objects.nonNull(dto.getEndTime())) {
      entity.setEndTime(dto.getEndTime());
    }
    if(Objects.nonNull(dto.getElectricityPrice())) {
      entity.setElectricityPrice(dto.getElectricityPrice());
    }
    if(Objects.nonNull(dto.getValleyType())) {
      entity.setValleyType(dto.getValleyType());
    }
    if(Objects.nonNull(dto.getRemark())) {
      entity.setRemark(dto.getRemark());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltPeakValleyTimeConfigRespVO entity2dto(BeltPeakValleyTimeConfig entity) {
    if (entity == null) {
      return null;
    }
    BeltPeakValleyTimeConfigRespVO dto = new BeltPeakValleyTimeConfigRespVO();
    dto.setId(entity.getId());
    dto.setStartTime(entity.getStartTime());
    dto.setEndTime(entity.getEndTime());
    dto.setElectricityPrice(entity.getElectricityPrice());
    dto.setValleyType(entity.getValleyType());
    dto.setRemark(entity.getRemark());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyTime(entity.getModifyTime());
    dto.setCreateUser(entity.getCreateUser());
    dto.setModifyUser(entity.getModifyUser());
    return dto;
  }

}
